package com.wang.myblog.mapper;

import com.wang.myblog.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CommentMapper {

    int insert(Comment comment);

    int deleteById(Integer id);

    int deleteByReplyId(Integer id);

    int deleteByArticleId(Integer id);

    Comment queryById(Integer id);

    List<Comment> queryAll(Comment comment);

    int update(Comment comment);

    List<Comment> queryByArticleIdAndType(@Param("aId") Integer aId, @Param("type") Integer type);

    List<Comment> queryReplyComment(Integer id);

    Integer getCount();

    Integer getUnReadCount();

    //获取最新读者评论（未读）
    List<Comment> queryUnRead(@Param("start") Integer start, @Param("limit") Integer limit);

    //根据文章id获取评论数量（不包括作者回复）
    Integer getCountByArticleId(Integer articleId);

    //获取评论
    List<Comment> queryByType(@Param("start") Integer start, @Param("limit") Integer limit, @Param("type") Integer type, @Param("searchMsg") String searchMsg);

    Integer getCountByType(@Param("type") Integer type, @Param("searchMsg") String searchMsg);
}
